/**
 * 
 */
package com.thor.palmmall.rest.inspect.converter;

import org.springframework.core.convert.converter.Converter;

import com.thor.commons.entity.UCN;
import com.thor.commons.util.ConverterUtil;
import com.thor.palmmall.rest.common.AAttachment2Converter;
import com.thor.palmmall.rest.common.OperateInfoConverter;
import com.thor.palmmall.rest.inspect.AInspectBill;
import com.thor.palmmall.spi.inspect.SInspectBill;

/**
 * @author NuoSa
 *
 * @since 1.0
 */
public class AInspectBillConverter implements Converter<SInspectBill, AInspectBill> {

  public static AInspectBillConverter getInstance() {
    if (instance == null)
      instance = new AInspectBillConverter();
    return instance;
  }

  private static AInspectBillConverter instance;

  private AInspectBillConverter() {
  }

  @Override
  public AInspectBill convert(SInspectBill source) {
    if (source == null) {
      return null;
    }
    AInspectBill target = new AInspectBill();
    target.setBeginTime(source.getBeginTime());
    target.setBillNumber(source.getBillNumber());
    target.setBizState(source.getBizState());
    target.setBpmInstance(source.getBpmInstance());
    target.setBpmMessage(source.getBpmMessage());
    target.setBpmState(source.getBpmState());
    target.setBuilding(UCN.newInstance(source.getBuilding()));
    target.setCategory(source.getCategory());
    target.setCategoryItem(source.getCategoryItem());
    target.setConfirmInfo(source.getConfirmInfo());
    target.setCreateInfo(OperateInfoConverter.getInstance().convert(source.getCreateInfo()));
    target
        .setLastModifyInfo(OperateInfoConverter.getInstance().convert(source.getLastModifyInfo()));
    target.setDealInfo(source.getDealInfo());
    target.setDutyPerson(UCN.newInstance(source.getDutyPerson()));
    target.setEndTime(source.getEndTime());
    target.setExpectTime(source.getExpectTime());
    target.setFloor(UCN.newInstance(source.getFloor()));
    target.setInspector(UCN.newInstance(source.getInspector()));
    target.setInspectTime(source.getInspectTime());
    target.setInspectTopic(source.getInspectTopic());
    target.setPermGroupId(source.getPermGroupId());
    target.setPermGroupTitle(source.getPermGroupTitle());
    target.setPlace(source.getPlace());
    target.setRemark(source.getRemark());
    target.setStore(UCN.newInstance(source.getStore()));
    target.setUuid(source.getUuid());
    target.setVersion(source.getVersion());
    target.setVersionTime(source.getVersionTime());
    target.setAfterPictures(
        ConverterUtil.convert(source.getAfterPictures(), AAttachment2Converter.getInstance()));
    target.setBeforePictures(
        ConverterUtil.convert(source.getBeforePictures(), AAttachment2Converter.getInstance()));
    
    target.setAbortMsg(source.getAbortMsg());
    return target;
  }

}
